<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script src="./LinkList.js"></script>
    <script>
        let link1 = new LinkedList();
        let link2 =  new LinkedList();
        link1.append(1)
        link1.append(4)
        link1.append(15)
        link1.append(89)
        link2.append(1)
        link2.append(4)
        link2.append(5)
        link2.append(15)    

        // 两个有序链表的公共部分

        let combineArr = [];
        let cur1 = link1.head;
        let cur2 = link2.head;
        while(cur1!==null&&cur2!==null){
            if(cur1.value<cur2.value){
                cur1 = cur1.next;
            }else if(cur1.value>cur2.value){
                cur2 = cur2.next;
            }else{
                combineArr.push(cur1.value);
                cur1 = cur1.next;
                cur2 = cur2.next;
            }
        }
        console.log(combineArr)

    </script>
</body>
</html>